﻿
namespace HSS.Xaml.UI.Data
{
	#region TrueVisibleValueConverter
	/// <summary>
	/// TrueVisibleValueConverter return <see cref="System.Windows.Visibility.Visible"/> when value is bool True
	/// otherwise returns <see cref="System.Windows.Visibility.Collapsed"/>.
	/// </summary>
	public class TrueVisibleValueConverter : System.Windows.Data.IValueConverter
	{
		/// <summary>
		/// Converts a bool True to <see cref="System.Windows.Visibility.Visible"/> and
		/// bool False to <see cref="System.Windows.Visibility.Collapsed"/>.
		/// </summary>
		/// <param name="value">A boolean value.</param>
		/// <param name="targetType"></param>
		/// <param name="parameter"></param>
		/// <param name="culture"></param>
		/// <returns><see cref="System.Windows.Visibility.Visible"/> if value is true; otherwise <see cref="System.Windows.Visibility.Collapsed"/>.</returns>
		public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value is System.Nullable<bool>)
			{
				System.Nullable<bool> val = (System.Nullable<bool>)value;
				if (val.HasValue && val.Value)
					return System.Windows.Visibility.Visible;
				else
					return System.Windows.Visibility.Collapsed;
			}
			else if (value is bool)
			{
				if ((bool)value)
					return System.Windows.Visibility.Visible;
				else
					return System.Windows.Visibility.Collapsed;
			}
			return System.Windows.Visibility.Visible;
		}
		/// <summary>
		/// Not used.
		/// </summary>
		/// <param name="value"></param>
		/// <param name="targetType"></param>
		/// <param name="parameter"></param>
		/// <param name="culture"></param>
		/// <returns><see cref="System.NotImplementedException"/>.</returns>
		public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new System.NotImplementedException();
		}
	}
	#endregion
}
